using System.Collections.Generic;

namespace NopSolutions.NopCommerce.BusinessLogic.Regions
{
    /// <summary>
    /// Extensions
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// Finds a ProductRegion item by specified identifiers
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="productId">Product identifier</param>
        /// <param name="RegionId">Region identifier</param>
        /// <returns>A ProductRegion that has the specified values; otherwise null</returns>
        public static ProductRegion FindProductRegion(this List<ProductRegion> source,
            int productId, int regionId)
        {
            foreach (ProductRegion productRegion in source)
                if (productRegion.ProductID == productId && productRegion.RegionID == regionId)
                    return productRegion;
            return null;
        }
    }
}
